// import { useParams } from "react-router-dom";
import { Key } from "react";
import { request } from "@utils/http";
import {
  IhospitalList,
  IhospitalListParams,
  IhospitalListResponse,
  ProvinceList,
  IhospitalDetailResponse,
  IdepList,
  status,
  IscheduleRuleParams,
  IscheduleRuleResponse,
  IScheduleList
} from "./model/hospitalListTypes";


export function reqHospitalList(params: IhospitalListParams) {
  const {
    page,
    limit,
    hosname,
    hoscode,
    hostype,
    provinceCode,
    cityCode,
    districtCode,
    status,
  } = params;

  return request.get<any, IhospitalListResponse>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
        hostype,
        provinceCode,
        cityCode,
        districtCode,
        status,
      },
    }
  );
}


// 获取省份数据
export const reqGetProvinceList=(dictCode = "province")=>{
  return request.get<any,ProvinceList>(`/admin/cmn/dict/findByDictCode/${dictCode}`)
}

// 获取市区数据
//parentId如果是1000,则返回医院等级的数据
export const reqGetCityOrDistrictList=(parentId:string)=>{
  return request.get<any,ProvinceList>(`/admin/cmn/dict/findByParentId/${parentId}`)
}

// 定义获取医院详情的函数
export function reqHospitalDetail(id: string) {
  return request.get<any, IhospitalDetailResponse>(
    `/admin/hosp/hospital/show/${id}`
  )
}
// 定义医院排班函数
export function reqHospitalSchedulDep(hoscode:string){
  return request.get<any,IdepList>(`/admin/hosp/department/${hoscode}`)
}
//更新医院状态
export function reqHospitalChangeStatus(id:string,status:0|1){
  return request.get<any,status>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}




//获取排班规则
export function regHospitalScheduleRule({page,limit,hoscode,depcode}:IscheduleRuleParams){
  return request.get<any,IscheduleRuleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)

}


export function reqHospitalScheduleList(
  hoscode: string,
  depcode: Key,
  workDate: string
) {
  return request.get<any, IScheduleList>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  )
}